package com.ddy.test.creditcardmanage.repository

import androidx.lifecycle.LiveData
import com.ddy.test.creditcardmanage.dao.CardDao
import com.ddy.test.creditcardmanage.model.Card
import com.ddy.test.creditcardmanage.model.CardRecord

class CardRepository(private val cardDao: CardDao) {

    fun getAllCards() : LiveData<List<Card>>{
        return cardDao.getAll()
    }

    fun getLiveCard(id: Long): LiveData<Card>{
        return cardDao.getLiveCardById(id)
    }

    fun getCard(id: Long): Card{
        return cardDao.getCardById(id)
    }



    fun addCard(card: Card) {
        return cardDao.addCard(card)
    }

    fun deleteCard(id: Long){
        return cardDao.deleteCard(id)
    }

    fun updateCard(card: Card){
        return cardDao.updateCard(card)
    }



    fun getAllCardRecords(cardId: Long): LiveData<List<CardRecord>>{
        return cardDao.getAllCardRecords(cardId)
    }

    fun getCardRecordsByTime(cardId: Long, from: Long, to: Long): LiveData<List<CardRecord>>{
        return cardDao.getCardRecordsByTime(cardId, from, to)
    }

    fun addCardRecord(cardRecord: CardRecord){
        return cardDao.addCardRecord(cardRecord)
    }

    fun deleteCardRecord(id: Long){
        return cardDao.deleteCardRecord(id)
    }

    fun deleteCardRecordByCard(id: Long) {
        return cardDao.deleteCardRecordByCard(id)
    }
}